/*
 * Intersection.h
 *
 *  Created on: Oct 31, 2009
 *      Author: jbarreneche
 */

#ifndef INTERSECTION_H_
#define INTERSECTION_H_
#include "MapPoint.h"
#include "util/MathUtils.h"
#include "util/LinkedList.h"

enum RoadNavigation {
	Left, Straight, Right
};

class RoadSegment;

class Intersection : public MapPoint {
public:
	Intersection(double x, double y) : MapPoint(x,y) {}
	virtual ~Intersection() {}
	virtual void intersect(RoadSegment* segment);
	virtual double angleFor(MapPoint &point) { return atan2((double)(point.getY() - this->getY()) , (double)(point.getX() - this->getX())) + PI / 2; }
	virtual double angleFor(RoadSegment* segment);
	virtual RoadSegment* navigate(RoadSegment* segment, RoadNavigation action) throw (util::ElementNotFoundException);
	virtual RoadSegment* roadTo(Intersection* intersection) throw (util::ElementNotFoundException);
protected:
	virtual double deltaAngleForAction(RoadNavigation action);
private:
	util::LinkedList<RoadSegment> segments;
};

#include "map/RoadSegment.h"

#endif /* INTERSECTION_H_ */
